LD = g++
CXX = g++
CXXFLAGS = -O2 -std=c++11

TARGET = a.out
SRCS = $(wildcard *.cc)
DEPS = $(patsubst %.cc,%.d,$(SRCS))
OBJS = $(patsubst %.cc,%.o,$(SRCS))

.PHONY: all clean

%.o: %.cc
	$(CXX) $(CXXFLAGS) -c -MMD -MP -o $@ $<

all: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) -o $@ $^

-include $(DEPS)

clean:
	rm -f $(TARGET) $(DEPS) $(OBJS)
